<!--mstp,sdh，ipran正常变更客户名称变更-->
<script>
import Common from "@/mixins/order/commonbg.js";
import OrderService from "@/api/order/OrderService.js";
import PPMForm from "@/crm3.0part7-ppm/core/ppmForm.vue";
export default {
  name: "mstp18411",
  mixins: [PPMForm, Common],
  data() {
    return {
      //mstp,sdh，ipran正常变更客户名称变更
    };
  },
  async mounted() {debugger
      await this.initCommon();

  },
  computed: {},
  methods: {
    isModContactLimit() {
      if(this.formData["20176-142000765"].value=='1'){
        this.SetRequired({ attrName:'合同终止日期', formkey:'20176-142002037', reqName:'empty', reqStatus:true});
      }else{
        this.SetRequired({ attrName:'合同终止日期', formkey:'20176-142002037', reqName:'empty', reqStatus:false});
      }
    },
    async payTypeChange(){
      debugger;
      if(this.formData["20176-100010204"].value=='30010001'){ //最终客户付费
        console.log( document.getElementById('20176-100010096').childNodes)
        document.getElementById('20176-100010096').childNodes.forEach((i) =>{
           if(i.tagName=='label'||i.tagName=='LABEL'){  
            i.innerHTML='付费客户';
          }
        });
        this.formData["20176-100010096"].value= this.formData["20176-100010088"].value;
        this.formData["20176-100010096"].text=this.formData["20176-100010088"].text;
        this.formData["20176-100010096"].disabled=true;
        //默认付费账户
        const result = await OrderService.executeSql({  interFaceType: "CUST", sqlId: 2021042901, paramStr: "custId:" + this.formData["20176-100010088"].value   }) 
        if (result.code == 200) {
          this.formData["20176-100010097"].text = result.meta.resList.executeSqlResp[0].acctName;
          this.formData["20176-100010097"].value =  result.meta.resList.executeSqlResp[0].acctId;
        }
      }else{
         this.formData["20176-100010096"].disabled=false;
         this.formData["20176-100010096"].text='';
         this.formData["20176-100010096"].value='';
         this.formData["20176-100010097"].text='';
         this.formData["20176-100010097"].value='';
         document.getElementById('20176-100010096').childNodes.forEach((i) =>{
          if(i.tagName=='label'||i.tagName=='LABEL'){  
            i.innerHTML='付费运营商';
          }
        });
       }
    },
    
    async getPluginValue(obj) {
      console.log(obj)
      let key = obj["key"];
     //客户名称
       if (key === "20176-100010088") {
        this.formData["20176-100012977"].value=obj.value.custAddr; //客户地址
        this.formData["20176-100012981"].value=obj.value.contactMobilePhone 	//联系电话
        this.formData["20176-100012975"].value=obj.value.contactName //联系人

          if(this.formData["20176-100010204"].value=='30010001'){ //最终客户付费
            console.log( document.getElementById('20176-100010096').childNodes)
            document.getElementById('20176-100010096').childNodes.forEach((i) =>{
            if(i.tagName=='label'||i.tagName=='LABEL'){  
                  i.innerHTML='付费客户';
                }
              });
            this.formData["20176-100010096"].value= this.formData["20176-100010088"].value;
            this.formData["20176-100010096"].text=this.formData["20176-100010088"].text;
            this.formData["20176-100010096"].disabled=true;
              //默认付费账户
            const result = await OrderService.executeSql({  interFaceType: "CUST", sqlId: 2021042901, paramStr: "custId:" + this.formData["20176-100010088"].value   }) 
            if (result.code == 200) { 
              this.formData["20176-100010097"].text = result.meta.resList.executeSqlResp[0].acctName;
              this.formData["20176-100010097"].value =  result.meta.resList.executeSqlResp[0].acctId;
            }
          }
      }
    },

  },
};
</script>

